let strarr = {
    'a-b-c-d':1,
    'a-b-c-e':2,
    'a-b-f':3,
    'a-j':4
}

let obj = {
    a:{
        b:{
            c:{
                d:1,
                e:2
            },
            f:3
        },
        j:4
    }
}

function ObjectStr2Tree(strarr) {
    let res = {}
    for (let item in strarr) {
        const arr = item.split('-')
        let obj = res
        for (let i = 0;i < arr.length - 1; i++) {
            obj[arr[i]] = obj[arr[i]] || {}
            obj = obj[arr[i]]
        }
        obj[arr[arr.length - 1]] = strarr[item]
    }
    return res
}

console.log(ObjectStr2Tree(strarr));
